mini.parse();

function MessageReplyHandler() {
}

MessageReplyHandler.instance = new MessageReplyHandler();
MessageReplyHandler.isQueryBtnExpended = false;

// 获得全局的商品类型数据表格对象
MessageReplyHandler.messageReplyGrid = mini.get("messageReplyGrid");

// 加载表格数据
MessageReplyHandler.messageReplyGrid.load({
			bumId : bumId
		});
		
MessageReplyHandler.returnMessages = function() {
	window.location.href = "memberMessages.jsp";
};

/**
 * 刷新页面数据及布局
 */
MessageReplyHandler.afresh = function() {
	window.location.href = "replyMessageList.jsp?bumId=" + bumId;
	mini.get("messageReplyPanel").doLayout();
};

MessageReplyHandler.messageReplyGrid.on("drawcell", function(e) {
			var record = e.record;
			var column = e.column;
			var field = e.field;
			var value = e.value;
			
			if (column.field == "briTime") {
				if (e.value.toString() != "") {
					e.cellHtml = changeDate(e.value, 6);
				} else {
					e.cellHtml = "";
				}
			}
		});

function onActionRenderer(e) {
	var s = '<a class="New_Button" href="javascript:void(0);" onclick="MessageReplyHandler.editReply();">查看/修改</a>'
			+ ' | '
			+ '<a class="New_Button" href="javascript:void(0);" onclick="MessageReplyHandler.deleteReply();">删除</a>';
	return s;
};

// 查看或修改回复
MessageReplyHandler.editReply = function() {
	var rowData = MessageReplyHandler.messageReplyGrid.getSelected();
	var rowsData = MessageReplyHandler.messageReplyGrid.getSelecteds();
	if (rowsData.length == 1) {
		miniWin.afreshNewWin();
		miniWin.setParams(650, 400, "查看/修改回复");
		miniWin.setOption("bodyStyle", "padding:0px;");
		miniWin.load("replyMessageView.jsp", function() {
					var iframe = miniWin.getIFrameEl();
					iframe.contentWindow.MessageReplyFormHandler
							.passData(rowData);
				}, function(action) {
					MessageReplyHandler.messageReplyGrid.reload();
				});
		miniWin.show();
	} else if (rowsData.length > 1) {
		MiniuiTools.miniWarning("系统提示", "不能同时编辑多条资源！");
	} else {
		MiniuiTools.miniWarning("系统提示", "请选择要编辑的资源！");
	}
};

// 删除回复
MessageReplyHandler.deleteReply = function() {
	var rowsData = MessageReplyHandler.messageReplyGrid.getSelecteds();
	
	if (rowsData.length == 1) {
		var str = "";
		
		for (var i = 0; i < rowsData.length; i++) {
			str += rowsData[i].briId + ",";
		}
		
		mini.confirm("确定删除记录？", "确定？", function(action) {
					if (action == "ok") {
						$.ajax({
									url : __root + "/deleteReply.do",
									type : "POST",
									data : {
										briId : str.substring(0, str.length - 1),
										lslUser: gbOperateUser,
				    					lslAddress: gbOperateIp
									},
									cache : false,
									success : function(text) {
										mini.alert("删除成功", "系统提示", null);
										MessageReplyHandler.messageReplyGrid
												.reload();
									}
								});
					}
				});

	} else {
		mini.alert("请选择删除的记录", "系统提示", null);
	}
};
